//
//  HMTabBar.m
//  OC版本新浪微博
//
//  Created by 赵少朋赵少朋 on 17/1/18.
//  Copyright © 2017年 ITheima. All rights reserved.
//

#import "HMTabBar.h"

@interface HMTabBar ()

@property (nonatomic, weak) UIButton *addButton;
@end

@implementation HMTabBar


- (void)layoutSubviews {

    //一定要写 不写会造成tabBar上的item无法点击
    [super layoutSubviews];
    
    CGFloat barItemW = ScreenW * 0.2;
    
    NSInteger index = 0;
    for (UIView *view in self.subviews) {
        
        Class class = NSClassFromString(@"UITabBarButton");
        
        if ([view isKindOfClass:class]) {
            
            CGRect tmpF = view.frame;
            tmpF.size.width = barItemW;
            tmpF.origin.x = index *barItemW;
            view.frame = tmpF;
            
            index++;
        }
        
        if (index == 2) {
            
            
            CGPoint cent = self.addButton.center;
            cent.x = self.frame.size.width * 0.5 ;
            cent.y = self.frame.size.height * 0.5;
            self.addButton.center = cent;
            index++;
        }
        
    }
    
    
    
}

- (instancetype)initWithFrame:(CGRect)frame {

    self = [super initWithFrame:frame];
    
    if (self) {
       
        [self setupUI];
    }
    return self;
    
}

- (void)setupUI {

    UIButton *addButton = [[UIButton alloc] init];
    [addButton setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
    [addButton setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateHighlighted];
    [addButton setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
    [addButton setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateHighlighted];
    
    [addButton sizeToFit];
    [self addSubview:addButton];
    
    self.addButton = addButton;
//    addButton.center = 
    //tabbar_compose_icon_add_highlighted
    
    //tabbar_compose_button_highlighted
}


@end
